﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="DocumentList.aspx.cs" Inherits="DocumentList" Title="Untitled Page" ValidateRequest="false" MaintainScrollPositionOnPostback="true" %>

<asp:Content ID="Content1" ContentPlaceHolderID="mainContentPlaceHolder" Runat="Server">
	<asp:LinqDataSource ID="LinqDataSource1" runat="server" 
		ContextTypeName="Cgd.Shell.Data.CgdShellDataContext" EnableDelete="True" 
		EnableInsert="True" EnableUpdate="True" TableName="Documents" 
		Where="Category=@Category" OrderBy="Time DESC">
		<WhereParameters>
			<asp:QueryStringParameter Name="Category" QueryStringField="c" Type="Int32" />
		</WhereParameters>
	</asp:LinqDataSource>
	<h2><asp:Label ID="lblSubtite" runat="server"></asp:Label></h2>
	
	<asp:DataPager ID="DataPager1" runat="server" PagedControlID="ListView1" 
		PageSize="20">
		<Fields>
			<asp:NextPreviousPagerField ShowFirstPageButton="True" 
				ShowNextPageButton="False" ShowPreviousPageButton="False" />
			<asp:NumericPagerField />
			<asp:NextPreviousPagerField ShowLastPageButton="True" 
				ShowNextPageButton="False" ShowPreviousPageButton="False" />
		</Fields>
	</asp:DataPager>
	<asp:ListView ID="ListView1" runat="server" DataSourceID="LinqDataSource1" 
		DataKeyNames="Id" ConvertEmptyStringToNull="False" 
		InsertItemPosition="FirstItem" oniteminserting="ListView1_ItemInserting" >
	<LayoutTemplate>
	<table>
	<tbody id="itemPlaceholder" runat="server"></tbody>
	</table>
	</LayoutTemplate>
	<ItemTemplate>
		<tr><td>
			<h3><a href='<%# Eval("Url") %>' target="_blank"><%# Eval("Title") %></a></h3>
			<p class="Summary"><%# Eval("Summary") %></p>
			<p class="Summary"><%# Eval("Time") %></p>
			<p class="ItemCommand">
				<asp:LinkButton ID="btnEdit" runat="server" CommandName="Edit" Text="编辑"></asp:LinkButton>
				<asp:LinkButton ID="btnDelete" runat="server" CommandName="Delete" OnClientClick="return confirm('确定要删除吗？\n该操作无法撤销。');" Text="删除"></asp:LinkButton>
			</p>
		</td></tr>
	</ItemTemplate>
	<ItemSeparatorTemplate>
	<tr><td><hr /></td></tr>
	</ItemSeparatorTemplate>
	<EditItemTemplate>
	<tr><td class="EditItem">
	<table>
	<tr><td>标题：</td><td><asp:TextBox ID="txtName" runat="server" Text='<%# Bind("Title") %>' Width="600px"></asp:TextBox></td></tr>
	<tr><td>URL：</td><td><asp:TextBox ID="txtUrl" runat="server" Text='<%# Bind("Url") %>' Width="600px"></asp:TextBox></td></tr>
	<tr><td>摘要：</td><td><asp:TextBox ID="txtSummary" runat="server" Text='<%# Bind("Summary") %>' Width="600px" TextMode="MultiLine"></asp:TextBox></td></tr>
	</table>
	<p class="ItemCommand">
	<asp:LinkButton ID="btnUpdate" runat="server" CommandName="Update" Text="确定"></asp:LinkButton>
	<asp:LinkButton ID="btnCancel" runat="server" CommandName="Cancel" Text="取消"></asp:LinkButton>
	</p>
	</td></tr>
	</EditItemTemplate>
	<InsertItemTemplate>
	<tr><td class="NewItem">
	<h3>添加新文档</h3>
	<table>
	<tr><td>标题：</td><td><asp:TextBox ID="txtName" runat="server" Text='<%# Bind("Title") %>' Width="600px"></asp:TextBox></td></tr>
	<tr><td>URL：</td><td><asp:TextBox ID="txtUrl" runat="server" Text='<%# Bind("Url") %>' Width="600px"></asp:TextBox></td></tr>
	<tr><td>摘要：</td><td><asp:TextBox ID="txtSummary" runat="server" Text='<%# Bind("Summary") %>' Width="600px" TextMode="MultiLine"></asp:TextBox></td></tr>
	</table>
	<p class="ItemCommand">
	<asp:LinkButton ID="btnInsert" runat="server" CommandName="Insert" Text="确定"></asp:LinkButton>
	<asp:LinkButton ID="btnCancel" runat="server" CommandName="Cancel" Text="取消"></asp:LinkButton>
	</p>
	</td></tr>
	</InsertItemTemplate>
	</asp:ListView>
	<asp:DataPager ID="DataPager2" runat="server" PagedControlID="ListView1" 
		PageSize="20">
		<Fields>
			<asp:NextPreviousPagerField ShowFirstPageButton="True" 
				ShowNextPageButton="False" ShowPreviousPageButton="False" />
			<asp:NumericPagerField />
			<asp:NextPreviousPagerField ShowLastPageButton="True" 
				ShowNextPageButton="False" ShowPreviousPageButton="False" />
		</Fields>
	</asp:DataPager>
</asp:Content>

